package com.example.travel.config;

import com.example.travel.interceptor.InterceptorLogin;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {

        //注册拦截器
        registry.addInterceptor(new InterceptorLogin())
                .addPathPatterns("/**")//拦截所有
        .excludePathPatterns(  //不拦截的静态资源和登录页
                "/login",  //登录页面
                "/toLogin", //登录请求
                "/**/*html",
                "/assets/**/*",
                "/css/**/*",
                "/fonts/**/*",
                "/icon/**/*",
                "/images/**/*",
                "/imag/**/*",
                "/js/**/*"
        );

    }
}
